package com.laich.springcloud.order.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.laich.springcloud.dto.UserInfo;
import com.laich.springcloud.entity.SysUser;
import com.laich.springcloud.feign.RemoteUserService;
import com.laich.springcloud.order.entity.OrderEntity;
import com.laich.springcloud.utils.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/ord")
@Api(value = "order", tags = "订单管理模块")
public class OrderController {

	@Autowired
	RemoteUserService remoteUserService;

	@GetMapping("/getUser/{username}")
	public R getUser(@PathVariable String username) {
		// for debug
		log.info("username:{}",username);
		return new R<>(remoteUserService.info(username, "Y"));
	}

	@GetMapping("/{id}")
	@ApiOperation(value = "id", notes = "订单ID")
	public R getOrder(@PathVariable String id) {
		log.info("id========================");
		// for debug
		OrderEntity order  =  new OrderEntity();
		order.setId(id);
		order.setUsername("laich");
		order.setOrderNo("orderNo001");
		log.info("id:{}",id);
		return new R<>(order);
	}

	@GetMapping("/orderUser/{username}")
	public R orderUser(@PathVariable String username) {
		// for debug
		R<UserInfo> user = remoteUserService.info(username, "Y");;
		return user;
	}

	/*
	 * @GetMapping("/list") public R list() { return "order/list"; }
	 */
}
